import React,{Component,useState,useEffect} from 'react';
import ReactDOM from 'react-dom';

function Counter(){
  const [number,setNumber] = useState(0);
  // 相当于componentDidMount 和 componentDidUpdate
  // useEffect(() => {
  //    console.log('开启一个新的定时器')
  //    const $timer = setInterval(()=>{
  //     setNumber(number=>number+1);
  //    },1000);
  // },[]);
  return (
      <>
          <p>{number}</p>
      </>
  )
}

ReactDOM.render(<Counter />, document.getElementById('root'));